package org.vogelsk.archangelsk;

import android.graphics.Canvas;

public class TankGameThread extends Thread{

	private Tanks tankView;
	private boolean running;
	
	public TankGameThread(Tanks t){
		tankView = t;
		
	}
	
	public void run() {
		while (running ==true){
		if (tankView.isInGame()) {
			tankView.checkCollision();
			tankView.checkFire();
			tankView.getAi().command();
			Canvas c = 	null;
			c = 	tankView.getHolder().lockCanvas();
            synchronized (	tankView.getHolder()) {

            	tankView.onDraw(c);

         }
        	tankView.getHolder().unlockCanvasAndPost(c);

		}
		}
		
	}

	public void setRunning(boolean b) {
		running = b;
		
	}
}
